#!/bin/bash

function rand()
{
    num=$(shuf -i $1-$2 -n 1)
    echo $num
}

function findPid()
{
    proc=`ps aux | grep $1 | grep -v grep`
    pid=`echo "$proc" | awk '{print $2}'`
    echo $pid
}

function waitProcessClose()
{
    line=`ps aux | grep $1 | grep -v "grep" | wc -l`
    while [ $line -ge 1 ]
    do
        sleep 5 
        line=`ps aux | grep $1 | grep -v "grep" | wc -l`
    done
}

function startProcessBackend()
{
    nohup $@ >/dev/null 2>&1 &
    echo "start $1: $!"
}
